/* 
 * File:   Thread.h
 * Author: Vicky.H
 * Email:  eclipser@163.com
 *
 * Created on 2014年1月17日, 下午4:28
 */

#ifndef CN_VICKY__THREAD_H
#define	CN_VICKY__THREAD_H

#include <sys/types.h>

typedef pthread_t TID;

//link: -lpthread
class Thread {
public:
    enum ThreadStatus {
        READY,          // 当前线程处于准备状态
        RUNNING,        // 处于运行状态
        EXITING,        // 线程正在退出
        EXIT            // 已经退出 
    };
public:
    Thread();
    virtual ~Thread();
public:
    // 线程开始
    void start();
    // 线程结束
    virtual void stop();
    // 线程退出
    void exit(void* retval = 0);
    // RUNhanshu 
    virtual void run();
public:
    TID getTID() {
        return m_TID;
    }
    ThreadStatus getStatus() {
        return m_Status;
    }
    void setStatus(ThreadStatus status) {
        m_Status = status;
    }
private:
    TID m_TID;
    // 线程状态
    ThreadStatus m_Status;
};

extern uint g_QuitThreadCount;

// 线程处理函数
void* ThreadProcess(void* derivedThread);

#endif	/* CN_VICKY__THREAD_H */

